﻿<!DOCTYPE html>
<html>
<!-- 培训课程管理 -->

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>
    <link href="/static/js/vue-treeselect/vue-treeselect.css" rel="stylesheet" />
    <script src="/static/js/vue-treeselect/vue-treeselect.js"></script>
    <style>
        .vue-treeselect__control {
            height: 100%;
            border: none;
            background: none;
        }

        .vue-treeselect__placeholder {
            top: -3px;
        }

        .vue-treeselect__single-value {
            top: -3px;
        }

        .el-input__suffix {
            /* z-index: 9; */
        }
    </style>
    <style>
        .el-input-number__increase {
            right: -4px;
        }

        .el-input-number.is-controls-right .el-input-number__decrease {
            right: -4px;
        }

        .el-input-number--mini {
            width: auto;
        }
    </style>
</head>

<body>
    <div id="app" class="popupW50" v-cloak>
        <el-row>
            <el-form label-position="right" :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="100px"
                     size="mini">
                <el-row>
                    <el-col :span="11">
                        <div class="elst-select-mini">
                            <el-form-item prop="pId">
                                <el-input size="mini">
                                    <template slot="prepend">
                                        {{'上级类别'+mark.m}}
                                    </template>
                                    <treeselect v-model="Form.pId"
                                                :options="DepartmentList"
                                                :flat="true"
                                                slot="suffix"
                                                style="line-height: 28px;width:70%;float: right;"
                                                placeholder="请选择" />
                                </el-input>
                                <span class="iputLineMust" v-if="!Form.pId">
                                    <!-- 必填项添加 -->
                                    <img src="/static/images/exclamation.png" alt="">
                                </span>
                            </el-form-item>
                        </div>
                    </el-col>
                    <el-col :span="11" offset="2">
                        <el-col>
                            <div class="elst-select-mini">
                                <el-form-item prop="name">
                                    <el-input type="text" v-model="Form.name" autocomplete="off" size="mini">
                                        <template slot="prepend">
                                            {{'类别名称'+mark.m}}
                                        </template>
                                    </el-input>
                                    <span class="iputLineMust" v-if="Form.name.length<=0">
                                        <!-- 必填项添加 -->
                                        <img src="/static/images/exclamation.png" alt="">
                                    </span>
                                </el-form-item>
                            </div>
                        </el-col>
                    </el-col>



                </el-row>
                <el-row type="flex" justify="end">
                    <el-form-item>
                        <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnSave}}</el-button>
                        <!--<el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnCommit}}</el-button>-->
                        <el-button type="primary" @click="parent.ListItem.dialogVisible=false">{{col.btnBack}}</el-button>
                    </el-form-item>
                </el-row>
            </el-form>
            <el-dialog title="选择培训老师" fullscreen="true" :visible.sync="ListItem.dialogVisible" @close='closeDialog'
                       width="80%" height="80%" top="10vh">
                <iframe ref="iframe" :src="ListItem.InputUrl" style="height:100%;width:100%" frameborder="0"></iframe>
            </el-dialog>
        </el-row>
    </div>
    <script type="text/javascript">
        var uploadText = "请选择上传文件";
        var app = new Vue({
            el: '#app',
            data: {
                //父业传参
                id: '',
                //业务表单内容
                Form: {
                    name: '',
                    pId: null
                },
                DepartmentList: [],//下拉树
               
                
                //表单验证
                rules: {
                    name: [
                        verification.NotNull,
                    ],
                    pId: [
                        verification.NotNull,
                    ],

                }
            },

            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                handleRemove: function (file) {
                    console.log(file);
                },
                handlePreview: function (file) {
                    console.log(file.name);
                    window.open(file.url)
                },

                onSubmitForm: function (formName) {
                    var mythis = this;

                    this.$refs[formName].validate(function (valid) {
                        //验证通过
                        if (valid) {

                            //var loadingObj = mythis.$loading(myloading);
                            onSubmitForm(this, '/api/Px_CourseClass/Save', mythis.Form);
                            //loadingObj.close();
                        } else {
                            //验证失败
                            return false;
                        }
                    });

                },


                getData: function () {
                    getData(this, '/api/Px_CourseClass/get?id=' + this.id);
                    if (!this.Form.pId)
                        this.Form.pId = guidEmpty;
                },

                //删除方法
                onDelete: function () { onDelete(this, '/api/TrainingCourseManagement/DeleteMuti'); },
                //列表选择触发
                UserInputStatistics: function (val, id) { DialogShow(this, val, "TrainingCourseManagementInputPerson.html", id); },
                handleSelectionChange: function (val) { handleSelectionChange(this, val); },
                //获取分页数据
                GetPageData: function (currentIndex) {
                    var dataSource = parent.ListItem.dataSource;

                    var data = MenuHelper(dataSource, guidEmpty);
                    this.DepartmentList = data;
                    this.DepartmentList.unshift({ id: guidEmpty, label: '无父级', Id: guidEmpty })
                },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                //跳页触发方法
                handleCurrentChange: function (val) { handleCurrentChange(this, val); },
                addTrainer: function (val, id) {
                    DialogShow(this, val, "TrainingPlanManagementluruInputTrainer.html", id);
                },
            },
            updated: function () {
                
            },
            mounted: function () {
                this.GetPageData(1);//绑定下拉树
                
                this.id = getUrlParam("id");
                this.getData();
                console.log('Form', this.Form);

            }

        });

        function MenuHelper(list, pid) {
            var result = [];
            list.forEach(function (v, i) {
               
                v.pId = v.pId ? v.pId : guidEmpty;
                if (v.pId == pid) {
                    var obj = v;
                    obj.id = obj.id + '';
                    obj.label = obj.name + '';
                    var nextObj = MenuHelper(list, v.id);
                    if (nextObj.length > 0) {
                        obj.children = nextObj;
                    }
                }
                if (obj)
                    result.push(obj)
            })
            return result;
        }
    </script>
</body>

</html>